package com.neu.his.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neu.his.entity.RegistLevel;
import com.neu.his.entity.VO.SystemManage01.RtManage.RtVO;
import com.neu.his.mapper.RegistLevelMapper;
import com.neu.his.service.RtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Description: neu-his
 * <p>
 * Created by 31316 on 2020/7/18 18:24
 */
@Service
public class RtServiceImpl implements RtService {
    @Autowired
    RegistLevelMapper registLevelMapper;

    @Override
    public List<RtVO> selectAllList(){
        List<RegistLevel> list = registLevelMapper.selectList(new QueryWrapper<RegistLevel>().ne("remove_mark",1));
        List<RtVO> result = new ArrayList<>();
        for (RegistLevel registLevel : list) {
            RtVO rtVO=new RtVO();
            rtVO.setId(registLevel.getId());
            rtVO.setRegistCode(registLevel.getRegistCode());
            rtVO.setRegistCost(registLevel.getRegistCost());
            rtVO.setRegistDefalut(registLevel.getRegistDefalut());
            rtVO.setRegistLevel(registLevel.getRegistLevel());
            rtVO.setRegistOrder(registLevel.getRegistOrder());
            result.add(rtVO);
        }
        Collections.sort(result, new Comparator<RtVO>(){
            @Override
            public int compare(RtVO o1, RtVO o2) {

                if(o1.getRegistOrder()>o2.getRegistOrder()){
                    return -1;
                }else{
                    return 1;
                }
            }
        });
        return result;
    }
}
